import { Injectable } from '@angular/core';
import { ToastController } from '@ionic/angular';

@Injectable({
    providedIn: 'root',
})
export class MyNoteService {

    constructor(private toastCtrl: ToastController) {

    }

    async MyNotice(message: string, time?: number, callback?, cssClass = 'my-note') {
        let toast;
        toast = await this.toastCtrl.create({
            message: message,
            duration: time || 1500,
            position: 'middle',
            cssClass: cssClass
        });
        toast.onDidDismiss().then(() => {
            if (callback) {
                callback();
            }
        });
        toast.present();
    }
}
